home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
051-075
/
disk_058
/
newzap
/
sources
/
beep.c
next >
Wrap
C/C++ Source or Header
|
1992-05-06
|
2KB
|
57 lines
/* BEEP.C - NewZAP support routines - (c) 1986 John Hodgson */
/* Absolute bare minimum beep routine. Allocates/deallocates all resources
during entry & exit. Very easy to spruce up! */
#define SOUNDPRIORITY 50; /* completely arbitrary */
extern struct Window *pwindow; /* so we can find the Workbench screen */
Beep()
{
struct IOAudio audioblock;
struct MsgPort *replyport=0,*CreatePort();
static UBYTE wave[] = {~127,~127,127,127}; /* cheapo square wave */
static UBYTE allocmap[] = {1,2,4,8}; /* any available channel */
long OpenDevice(),WaitIO();
UBYTE *wavesample;
setmem(&audioblock,sizeof(audioblock),0); /* start fresh */
if ((replyport=CreatePort(0L,0L))==0) {
DisplayBeep(pwindow->WScreen); /* flash if can't beep */
return(0);
}
/* prepare for ALLOCATE */
audioblock.ioa_Data=&allocmap[0];
audioblock.ioa_Length=sizeof(allocmap);
audioblock.ioa_Request.io_Message.mn_ReplyPort=replyport;
audioblock.ioa_Request.io_Message.mn_Node.ln_Pri=SOUNDPRIORITY;
/* attempt to ADCMD_ALLOCATE while opening */
if (OpenDevice("audio.device",0L,&audioblock,0L)) {
DeletePort(replyport);
DisplayBeep(pwindow->WScreen);
return(0); /* back if no channel available */
}
audioblock.ioa_Request.io_Command=CMD_WRITE;
audioblock.ioa_Request.io_Flags=ADIOF_PERVOL;
audioblock.ioa_Period=447; /* 2000 Hz for this waveform */
audioblock.ioa_Volume=64/2; /* half volume */
audioblock.ioa_Cycles=150; /* 1/15 sec. */
audioblock.ioa_Data=&wave[0];
audioblock.ioa_Length=sizeof(wave);
BeginIO(&audioblock);
if (WaitIO(&audioblock)) DisplayBeep(pwindow->WScreen);
CloseDevice(&audioblock); /* clean up now */
DeletePort(audioblock.ioa_Request.io_Message.mn_ReplyPort);
}